
function addformimagewidth()
{


   $("#addform").append('<div id="feature'+rowdiv+'" class="itPlg addImgPlg featureclass">'+dataform['imagewidth']+"</div>");
   var rownow=rowdiv;


  var rowgnow=1;
  
  
   $('#feature'+rownow+' .uploadbutton').iuploader({
         'link':serviceinfo+'iupload',
         'accept':'image/*',
         'group':rowgnow,

         'type':['jpg', 'jpeg', 'png', 'gif'],
         'onUploadFinish':function(filename,filelink,setting){
         
          getpopupboxresize(640,0,filelink,setting['originalwidth'],setting['originalheight'],
         
         function(filename2,filelink2,width2,height2,imgmid2){
         
         var rowgnow2=setting['group'];        
         
         
         
         
         $('#feature'+rownow+' .image'+rowgnow2+' .plgArea').html('<a target="_blank" href="'+filelink+'?t='+Math.floor((Math.random()*100000)+1)+'"><img  width="640" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelink[]"]').val(filelink);
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelinkcrop[]"]').val(filelink2);                 
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="fileold[]"]').val(setting.fileold);      
         $("#width-"+setting.id).val(setting.originalwidth);
         $("#height-"+setting.id).val(setting.originalheight);      
         $("#imgmid-"+setting.id).val(setting.imgmid);       
         $("#simgmid-"+setting.id).val(imgmid2);               
         $("#widthcrop-"+setting.id).val(width2);
         $("#heightcrop-"+setting.id).val(height2);    
         
          closepopup();  
         }
         ,setting['imgmid']
         ,1
         );
         
         
        
         //alert(filename);
         }
   });
  
  
   $('#feature'+rownow+' .cloudbutton').click(function() {
          //console.log("testdata");
          //var rowgnow3=rowgnow;
          var rowgnow3=1;
        //alert("Handler for .click() called.");
          getpopupcloud(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 

        $('#feature'+rownow+' .image'+rowgnow3+' .plgArea').html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img  width="640" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);

        closepopup();  

          
          },
          
          
          function(filename,filelink,width,height,imgmid,indexnow){
            
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,640
          ,0
          ,1
          );

   });
   
   $('#feature'+rownow+' .deletebutton').click(function() {
   
   var rowgnow3=1;
   

   $('#feature'+rownow+' .image'+rowgnow3+' .plgArea a').remove();
   
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val('');           
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val('');
   
   
   
    $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val('');
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val('');                                    
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val('');         
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val('');
   
   });
   
   $('#feature'+rownow+' .linkbutton').click(function() {
   var rowgnow3=1;
   //console.log("test");
   
   getpopuplink(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 
          
          
         $('#feature'+rownow+' .image'+rowgnow3+' .plgArea').html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img  width="640" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);
        // $.colorbox.close("User added succesfully"); 
        closepopup();  
          
          },
          function(filename,filelink,width,height,imgmid,indexnow){
            

            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,640
          ,0
          ,1
   );
   
   });
   
   
   
   $('#feature'+rownow+' .deleterowbutton').click(function(){
   
    $('#feature'+rownow).remove();
    
   });
  
  
 
  
 
  
  
  
  
  
  
  
  
  
  
  
  //$('#feature'+rownow+' .group')
   
   
  
   

  
  
   rowdiv++;
}
function saveformimagewidth(id,plugid)
{
        var obj={};
        var imgmid1=$("#"+id+' .image1 input[name="imgmid[]"]').val();
        var simgmid1=$("#"+id+' .image1 input[name="simgmid[]"]').val();
        detail=$("#"+id+' input[name="detail[]"]').val();
        if(imgmid1)
        {
        obj={plugid:plugid,imgmid:imgmid1,simgmid:simgmid1,detail:detail};
        
        }else
        {
        obj={'code':'22','msg':'Requied Image','error':1};
        }
        
        
       
        return obj;
}
function getformimagewidth_bk(dataplugin)
{
var code = '<div class="ldIt wrpImgLd clBg4 w640" onclick="openmaingallery('+dataplugin.simgmid+')">\n';
code += '<div class="icoDefLd">\n';
code += '<span class="ico icoImgDefLd"></span>\n';
code += '<span>Image</span>\n';
code += '</div>\n';
code += '<div class="wrpImgDesLd">\n';
code += '<a href="javascript:void(0)"   class="galleryimage" ><img  title="'+dataplugin.img.newpath+'"   alt="'+dataplugin.img.width+'|'+dataplugin.img.height+'" id="img-'+dataplugin.simgmid+'" src="'+dataplugin.simg.newpath+'"></a>\n';

var displayset="";
if(dataplugin.detail=="")
{
displayset='style="display:none"';
}

code += '<div class="desImgLd clTxtW" '+displayset+'>\n';
code += '<div class="ovlLd ovlImgLd w640" >\n';
code += '<p class="cutTxt">'+dataplugin.detail+'</p>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';
return code;


}
function getformimagewidth(dataplugin)
{
var code = '<div class="ldIt wrpImgLd clBg4 w640" onclick="openmaingallery('+dataplugin.simgmid+')">\n';
code += '<div class="icoDefLd">\n';
code += '<span class="ico icoImgDefLd"></span>\n';
code += '<span></span>\n';
code += '</div>\n';
code += '<div class="wrpImgDesLd">\n';
code += '<a href="javascript:void(0)"   class="galleryimage" ><img  title="'+dataplugin.img.newpath+'"   alt="'+dataplugin.img.width+'|'+dataplugin.img.height+'" id="img-'+dataplugin.simgmid+'" src="'+dataplugin.simg.newpath+'"></a>\n';
var displayset="";
if(dataplugin.detail=="")
{
displayset='style="display:none"';
}
code += '<div class="desImgLd clTxtW" '+displayset+' >\n';
code += '<div class="ovlLd ovlImgLd w640" >\n';
code += '<p class="cutTxt">'+dataplugin.detail+'</p>\n';
code += '</div>\n';
code += '</div>\n';


code += '</div>\n';
code += '</div>';

var arraydata=dataplugin;

 if(arraydata['other']['IFD0'])
 {
 var model='';
 if(arraydata['other']['IFD0']['Model'])
 {
 model=arraydata['other']['IFD0']['Model'];
 
 }
 
 
 var len='';
 if(arraydata['other']['EXIF'])
 {
 if(arraydata['other']['EXIF']['UndefinedTag:0xA434'])
 {
 len=arraydata['other']['EXIF']['UndefinedTag:0xA434'];
 }
 
 }
 
 
 var  focus='';
 if(arraydata['other']['EXIF'])
 {
 if(arraydata['other']['EXIF']['FocalLength'])
 {
 focus=arraydata['other']['EXIF']['FocalLength'];
 }
 
 }
 
 
 
 var shutter='';
 if(arraydata['other']['EXIF'])
 {
 if(arraydata['other']['EXIF']['ISOSpeedRatings'])
 {
 shutter=arraydata['other']['EXIF']['ISOSpeedRatings'];
 }
 }
 
 var aperture='';
  if(arraydata['other']['COMPUTED'])
 {
 if(arraydata['other']['COMPUTED']['ApertureFNumber'])
 {
 aperture=arraydata['other']['COMPUTED']['ApertureFNumber'];
 }
 }
 
 
 var exposure='';
  if(arraydata['other']['EXIF'])
 {
 if(arraydata['other']['EXIF']['ExposureTime'])
 {
 exposure=arraydata['other']['EXIF']['ExposureTime'];
 }
 }
 
 
 var  createdate='';
  if(arraydata['other']['IFD0'])
 {
 if(arraydata['other']['IFD0']['DateTime'])
 {
 createdate=arraydata['other']['IFD0']['DateTime'];
 }
 }
 
 
 
 var artist='';
  if(arraydata['other']['IFD0'])
 {
 if(arraydata['other']['IFD0']['Artist'])
 {
 artist=arraydata['other']['IFD0']['Artist'];
 }
 }
 
//
//  echo "<pre>";
// print_r(arraydata);
// echo "</pre>;";
// exit;
 
code += '<div class="ldIt wrpNewExifData">';
code += '<ul class="clearfix">';
var linktext='';
if(model)
{
code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/Model/'+model+'\')">';
code += '<div class="newExifData clearfix modlExif">';
code += '<span class="ico4 icoModlExif"></span>';
code += '<span class="spnNewExif">'+model+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPopModlExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popModlExif">';
code += '<span>Camera Model</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}

if(len)
{
linktext=len.replace(/\//g,'ppset');
code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/UndefinedTag:0xA434/'+linktext+'\')">';
code += '<div class="newExifData clearfix lensExif">';
code += '<span class="ico4 icoLensExif"></span>';
code += '<span class="spnNewExif">'+len+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPoplensExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popLensExif">';
code += '<span>Lens</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}

if(focus)
{
linktext=focus.replace(/\//g,'-');
var res = focus.split("/"); 
focus=(res[0]/res[1])+' mm';
code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/FocalLength/'+linktext+'\')">';
code += '<div class="newExifData clearfix foclExif">';
code += '<span class="ico4 icoFoclExif"></span>';
code += '<span class="spnNewExif">'+focus+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPopFoclExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popFoclExif">';
code += '<span>Focal Length</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}

if(exposure)
{
linktext=exposure.replace(/\//g,'-');
code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/ExposureTime/'+linktext+'\')">';
code += '<div class="newExifData clearfix spedExif">';
code += '<span class="ico4 icoSpedExif"></span>';
code += '<span class="spnNewExif">'+exposure+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPopSpedExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popSpedExif">';
code += '<span>Exposure Time</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}

if(aperture)
{
linktext=aperture.replace(/\//g,'-');
code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/ApertureFNumber/'+linktext+'\')">';
code += '<div class="newExifData clearfix aptrExif">';
code += '<span class="ico4 icoAptrExif"></span>';
code += '<span class="spnNewExif">'+aperture+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPopAptrExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popAptrExif">';
code += '<span>Aperture</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}

if(shutter)
{
shutter=shutter+'';
linktext=shutter.replace(/\//g,'-');
code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/ISOSpeedRatings/'+linktext+'\')">';
code += '<div class="newExifData clearfix isoExif">';
code += '<span class="ico4 icoIsoExif"></span>';
code += '<span class="spnNewExif">'+shutter+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPopIsoExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popIsoExif">';
code += '<span>ISO/Film</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}

//code += '<li class="wrpOutNewExifData">';
//code += '<div class="newExifData clearfix lctExif">';
//code += '<span class="ico4 icoLctExif"></span>';
//code += '<span class="spnNewExif">1231414.12414</span>';
//code += '</div>';
//code += '<div class="wrpPopExif wrpPopLctExif">';
//code += '<div class="wrpInPopExif">';
//code += '<div class="popExif popLctExif">';
//code += '<span>Latitude and Longitude</span>';
//code += '</div>';
//code += '<div class="triExif"></div>';
//code += '</div>';
//code += '</div>';
//code += '</li>';

if(createdate)
{
var res = createdate.split(" "); 
var res2 = res[0].split(":"); 
createdate = res2[2]+'/'+res2[1]+'/'+res2[0]; 

code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/DateTime/'+res[0]+'\')">';
code += '<div class="newExifData clearfix dateExif">';
code += '<span class="ico4 icoDateExif"></span>';
code += '<span class="spnNewExif">'+createdate+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPopDateExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popDateExif">';
code += '<span>Create Date</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}

if(artist)
{
linktext=artist.replace(/\//g,'-');
code += '<li class="wrpOutNewExifData" onclick="linkto(\''+baseinfo+'/exifdata/Artist/'+linktext+'\')">';
code += '<div class="newExifData clearfix artsExif">';
code += '<span class="ico4 icoArtsExif"></span>';
code += '<span class="spnNewExif">'+artist+'</span>';
code += '</div>';
code += '<div class="wrpPopExif wrpPopArtsExif">';
code += '<div class="wrpInPopExif">';
code += '<div class="popExif popArtsExif">';
code += '<span>Artist</span>';
code += '</div>';
code += '<div class="triExif"></div>';
code += '</div>';
code += '</div>';
code += '</li>';
}


code += '</ul>';
code += '</div>';
 }

return code;


}
function editformimagewidth(datarow)
{
       addformimagewidth();

       var rownow= rowdiv-1;
       var rowgnow2=1;
       
       
    $('#feature'+rownow+' .image'+rowgnow2+' .plgArea').html('<a target="_blank" href="'+datarow.img.newpath+'?t='+Math.floor((Math.random()*100000)+1)+'"><img  width="640" src="'+datarow.simg.newpath+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
    $('#feature'+rownow+' .image'+rowgnow2+' input[name="imgmid[]"]').val(datarow.imgmid);
    $('#feature'+rownow+' .image'+rowgnow2+' input[name="simgmid[]"]').val(datarow.simgmid);
    $('#feature'+rownow+' input[name="detail[]"]').val(datarow.detail);   


}